/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

@import '../custom.less';
@import './vars.less';

@loading-prefix-cls: ~'@{css-prefix}loading';

.@{loading-prefix-cls} {
  .component-css-vars-loading();

  &__mask {
    position: absolute;
    z-index: 2000;
    background-color: var(--ti-loading-mask-bg-color);
    margin: 0;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transition: opacity 0.3s;

    &.is-fullscreen {
      position: fixed;

      .@{loading-prefix-cls}__spinner {
        margin-top: -25px;

        &-small {
          svg {
            height: var(--ti-loading-fullscreen-small-height);
            width: var(--ti-loading-fullscreen-small-width);
          }
        }

        &-medium {
          svg {
            height: var(--ti-loading-fullscreen-medium-height);
            width: var(--ti-loading-fullscreen-medium-width);
          }
        }

        &-large {
          svg {
            height: var(--ti-loading-fullscreen-large-height);
            width: var(--ti-loading-fullscreen-large-width);
          }
        }
      }
    }
  }

  &__spinner {
    top: 50%;
    margin-top: var(--ti-loading-spinner-margin-top);
    width: 100%;
    text-align: center;
    position: absolute;

    .@{loading-prefix-cls}__text {
      color: var(--ti-loading-text-color);
      margin: var(--ti-loading-text-margin-vertical) var(--ti-loading-text-margin-horizontal);
      font-size: var(--ti-loading-text-font-size);
    }

    &-small {
      svg {
        height: var(--ti-loading-spinner-small-height);
        width: var(--ti-loading-spinner-small-width);
      }
    }

    &-medium {
      svg {
        height: var(--ti-loading-spinner-medium-height);
        width: var(--ti-loading-spinner-medium-width);
      }
    }

    &-large {
      svg {
        height: var(--ti-loading-spinner-large-height);
        width: var(--ti-loading-spinner-large-width);
      }
    }

    .circular {
      animation: loading-rotate 2s linear infinite;
    }

    .path {
      animation: loading-dash 1.5s ease-in-out infinite;
      stroke-dasharray: 90, 150;
      stroke-dashoffset: 0;
      stroke-width: 2;
      stroke: var(--ti-loading-text-color);
      stroke-linecap: round;
    }

    svg {
      fill: var(--ti-loading-text-color);
    }
  }

  &__parent-relative {
    position: relative !important;
  }

  &__parent-hidden {
    overflow: hidden !important;
  }

  &-fade-enter,
  &-fade-leave-active {
    opacity: 0;
  }
}

@keyframes loading-rotate {
  100% {
    transform: rotate(360deg);
  }
}

@keyframes loading-dash {
  0% {
    stroke-dasharray: 1, 200;
    stroke-dashoffset: 0;
  }

  50% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -40px;
  }

  100% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -120px;
  }
}

.@{css-prefix-iconfont}-loading {
  font-size: var(--ti-common-font-size-1);
  line-height: 1;
  vertical-align: text-top;
  animation: rotating 2s linear infinite;
}

@keyframes rotating {
  0% {
    transform: rotateZ(0deg);
  }

  100% {
    transform: rotateZ(360deg);
  }
}
